package com.itcast.demo_one.kotlin

fun main(args: Array<String>) {
    // 1. 使用主构造函数创建对象
    val man = Person5("张三")
    man.show()

    val women = Person5("李思思")
    women.show()

    // 2. 使用次构造函数创建对象
    val man2 = Person5("张三", 18)
    man2.intro()

    // 3. 使用次构造函数创建对象
    val women2 = Person5("李可可", 18, 90)
    women2.showScore()


}

class Person5(var name: String){
    var age: Int = 0
    var score: Int = 0

    // 次构造函数1
    constructor(name: String, age: Int) : this(name){
        this.age = age
    }

    // 次构造函数2
    constructor(name: String, age: Int, score: Int) : this(name){
        this.age = age
        this.score = score
    }

    fun show(){
        println("姓名: $name")
    }

    fun intro(){
        println("姓名: $name, 年龄: $age")
    }

    fun showScore(){
        println("姓名: $name, 年龄: $age, 分数: $score")
    }
}